import type { AddressItem, AddressType } from '@/types/address'
import { http } from '@/utils/http'
// 获取地址
export const getAddressAPI = () => {
  return http<AddressType[]>({
    url: '/member/address',
    method: 'GET',
  })
}
// 添加地址
export const addAddressAPI = (address: AddressItem) => {
  return http<{ id: string }>({
    url: '/member/address',
    method: 'POST',
    data: {
      address,
    },
  })
}
// 修改地址
export const updateAddressAPI = (addressId: string, address: AddressItem) => {
  return http<{ id: string }>({
    url: `/member/address/${addressId}`,
    method: 'PUT',
    data: {
      address,
    },
  })
}
// 删除地址
export const deleteAddressAPI = (addressId: string) => {
  return http<{ id: number }>({
    url: `/member/address/${addressId}`,
    method: 'DELETE',
  })
}
